<template>
  <div class="unlogin-container">
    <button type="button" class="mui-btn mui-btn-danger unloginbtn" @click="unlogin">退出登录</button>
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  computed: {
    ...mapState(['currentLoginUser'])
  },
  methods: {
    unlogin() {
      /*
      修改数据库中已经登录了的用户
      */
      let params = this.currentLoginUser
      this.axios.post('/api/login/exitLogin', params)
        .then((response) => {
          // 响应成功回调
          console.log(response, '当前登录的用户退出成功')
          this.$imconn.close()
          this.$router.push('/login')
        })
        .catch(err => {
          console.log(err, '当前登录的用户退出失败')
          this.$router.push('/login')
        })
      /*
      修改完数据库之后跳转登录的页面
      */
    }
  }
}
</script>

<style lang='scss' scoped>
.unlogin-container{
  width: 100vw;
  height: 100vh;
  text-align: center;
  .unloginbtn {
    text-align: center;
    width: 90%;
    height: 40px;
    font-size: 20px;
  }
}
</style>
